#include <bits/stdc++.h>
using namespace std;

const int N = 32;
int n, m;
int dx[4] = { 0, 0, 1, -1 }, dy[4] = { 1, -1, 0, 0 };
char a[N][N];
int dist[N][N];
int x, y;

void bfs()
{
    memset(dist, -1, sizeof dist);
    queue <pair<int, int>> q;
    q.push({ x, y });
    dist[x][y] = 0;
    while (q.size())
    {
        auto t = q.front();
        q.pop();
        int i = t.first, j = t.second;
        for (int k = 0; k < 4; k++)
        {
            int x = dx[k] + i, y = dy[k] + j;
            if (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] != '*' && dist[x][y] == -1)
            {
                dist[x][y] = dist[i][j] + 1;
                if (a[x][y] == 'e')
                    continue;

                q.push({ x, y });
            }
        }
    }
}
int main()
{
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
            if (a[i][j] == 'k')
                x = i, y = j;
        }
    }

    bfs();
    int cnt = 0, ret = 1e9;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j] == 'e' && dist[i][j] != -1)
            {
                cnt++;
                ret = min(ret, dist[i][j]);
            }
        }
    }

    if (cnt == 0) cout << -1 << endl;
    else cout << cnt << " " << ret << endl;

    return 0;
}